package com.epoint.mobileoa.personalized.epointcompany.bizlogic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.personalized.epointcompany.model.GongzuoRzBaoxiaoModel;
import com.epoint.mobileoa.personalized.epointcompany.model.MissionInfoModel;

/**
 * @author liyc
 * @time 2012-4-13 下午1:52:42
 * @annotation 获取任务列表
 */
public class BindMissionInfoTask extends Task {

	public BindMissionInfoTask(SuperView con, HashMap<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {
		String seamurl = generateURL("Epoint_BindMissionInfo",getFP().getUserguid());
		String bs = HttpHelp.getHttpBack(seamurl);
		setMessageToRefreshUI(mess, getCon(),bs);
	}
	
	public static List<MissionInfoModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<MissionInfoModel> plist = new ArrayList<MissionInfoModel>();
		for (int i = 0; i < focs.size(); i++) {
			MissionInfoModel mt = new MissionInfoModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("RowGuid") != null)
				mt.RowGuid = foc.elementText("RowGuid");
			if (foc.element("MissionName") != null)
				mt.MissionName = foc.elementText("MissionName");
			if (foc.element("ProjectGuid") != null)
				mt.ProjectGuid = foc.elementText("ProjectGuid");
			if (foc.element("ProjectName") != null)
				mt.ProjectName = foc.elementText("ProjectName");
			if (foc.element("PlanRowGuid") != null)
				mt.PlanRowGuid = foc.elementText("PlanRowGuid");
			if (foc.element("Priority") != null)
				mt.Priority = foc.elementText("Priority");
			if (foc.element("FinishPersonGuid") != null)
				mt.FinishPersonGuid = foc.elementText("FinishPersonGuid");
			if (foc.element("FinishPersonName") != null)
				mt.FinishPersonName = foc.elementText("FinishPersonName");
			if (foc.element("BeginDate") != null)
				mt.BeginDate = foc.elementText("BeginDate");
			if (foc.element("FinishDate") != null)
				mt.FinishDate = foc.elementText("FinishDate");
			if (foc.element("CompletePercent") != null)
				mt.CompletePercent = foc.elementText("CompletePercent");
			if (foc.element("SenderGuid") != null)
				mt.SenderGuid = foc.elementText("SenderGuid");
			if (foc.element("MissionState") != null)
				mt.MissionState = foc.elementText("MissionState");
			if (foc.element("MissionType") != null)
				mt.MissionType = foc.elementText("MissionType");
			if (foc.element("ProjectMissionType") != null)
				mt.ProjectMissionType = foc.elementText("ProjectMissionType");
			if (foc.element("Flag") != null)
				mt.Flag = foc.elementText("Flag");
			if (foc.element("cnt") != null)
				mt.cnt = foc.elementText("cnt");
			plist.add(mt);
		}
		return plist;
	}

}
